package com.house.reportisy;

import com.house.entity.Message;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Map;

/**
 * @author: GGP
 * @description: 留言DAO
 * @time: 2023-04-17 20:22
 **/
public interface MessageRepository extends JpaRepository<Message,Integer>, JpaSpecificationExecutor<Message> {
	@Query(value = "select m.id, u.username,m.message,m.create_date as createDate"+
	" from message as m join user as u on m.user_id=u.id where m.house_id=:houseId",nativeQuery = true
	)
	List<Map<String,Object>> findAllMessage(@Param("houseId") Integer houseId);
}
